home *** CD-ROM | disk | FTP | other *** search
- Path: malgudi.oar.net!usenet
- From: Kevin Finley <kfinley@carsinfo.com>
- Newsgroups: comp.lang.c++
- Subject: More questions on generic/templated classes
- Date: 20 Mar 1996 21:30:09 GMT
- Organization: OARnet
- Message-ID: <4iptd1$cqh@ns.oar.net>
- NNTP-Posting-Host: probe.carsinfo.com
-
- Hi all,
- First, in reference to Josh in article 167766, yes you can
- use typedefs with templates. My experience indicates they are
- simply a convenience (and a mighty nice on I might add:)
- Second, from my prototyping, it seems that most compilers
- compile templates the first time they need to instantiate an
- object of that type. Some compilers seem to compile template
- code the first time they run into a declaration - such as
- "typedef blah<x> blah_x;" Also, from my prototyping, your
- worry about multiple compilations within one source file seems
- unfounded - templates are compiled the first time necessary
- in a source file and that is reused.
- However, now we come to my question. g++ (I haven't checked
- my other compilers yet and thought I would look to net wisdom)
- seems to compile this code for each and every source file and
- will not allow extern as extern and typedef are both type
- modifiers. Does anyone know a way to make the linker look
- for the code to match a template in another object.
- Note that I was surprised to see g++ generate the same
- mangled name three times for the same template and functions
- and have all three successfully link into my executable.
- Also not that the results seem to be the same when I declare
- a class which extends the template - such as
- "class x : public blah<int>"
-
- TIA
- Kevin Finley
- CARS Information Systems Corp (CIS)
-